/* GZIP by Raccoon Framework */ /* main.js */ var _ = {}; _.extend = jQuery.extend; var alert_old = window.alert; var alert = function(message, callback) { $.blockUI({ message: "" + "
" + "

"+message+"

" + "" + "

" }); $("div.alert_window input.btn").click(function(){ $.unblockUI(); if (typeof callback === 'function') { callback(); } }); } var confirm_old = window.confirm; var confirm = function(message, callback) { $.blockUI({ message: "" + "
" + "

"+message+"

" + "" + "" + "

" }); $("div.alert_window input.ok").click(function(){ $.unblockUI(); if (typeof callback === 'function') { callback(true); } }); $("div.alert_window input.no").click(function(){ $.unblockUI(); if (typeof callback === 'function') { callback(false); } }); } var loading = function(message) { if (!message || message === "" || message === null || message === false) { message = "Procesando..."; } $.blockUI({ message: "" + "

"+message+"

" + "" }); } _.extend({ mail_regexp : /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/, alert : function(message, callback) { $.blockUI({ message: "" + "

" + "

"+message+"

" + "" + "

" }); $("div.alert_window button#btn_ok").click(function(){ $.unblockUI(); if (typeof callback === 'function') { callback(); } }); }, confirm : function(message, callback) { $.blockUI({ message: "" + "
" + "

"+message+"

" + "" + "" + "

" }); $("div.alert_window button#btn_ok").click(function(){ $.unblockUI(); if (typeof callback === 'function') { callback(true); } }); $("div.alert_window button#btn_cancel").click(function(){ $.unblockUI(); if (typeof callback === 'function') { callback(false); } }); }, loading: function(message) { if (!message || message === "" || message === null || message === false) { message = "Procesando...."; } $.blockUI({ message: "" + "

"+message+"

" + "" }); }, search: function() { var busqueda = $('#campo_buscar').val(); window.location.href = RCN.url + 'index.php/page,search/for,' + encodeURI(busqueda); } }); /* users.js */ _.extend({ users: { login: function() { $.blockUI({ message: $('#login'), css: { width: '350px' } }); $('#login #login_cancel').click(function(){ $('#login #login_error_msg').html(''); $.unblockUI(); }); $('#login #login_send').click(function() { $('#login #login_error_msg').html('Procesando...'); $.post("index.php/mode,json/control,Users.validateLogin/", { email: $('input#login_email').val(), password: $('input#login_password').val() }, function(json) { if (json.status === "OK") { window.location.reload(); } else { $('#login #login_error_msg').html('Usuario o contraseña incorrectos'); } }, "json"); }); }, loginChat: function() { loading(); $.post("index.php/mode,json/control,Users.validateLogin/", { email: $('input#login_email_chat').val(), password: $('input#login_password_chat').val() }, function(json) { if (json.status === "OK") { location.href = RCN.url + "index.php/page,chat" } else { alert('Usuario o contraseña incorrectos'); } }, "json"); }, logout: function() { $.post("index.php/mode,json/control,Users.logOut/", function() { location.href = RCN.url + "index.php"; }); }, registry: function() { $.blockUI({ message: $('#registry'), css: { top: ($(window).height() - 350) /2 + 'px', left: ($(window).width() - 550) /2 + 'px', width: '550px' } }); $('#registry #btn_cancel').click(function(){ $('#registry #registry_error_msg').html(''); $.unblockUI(); }); $('#registry #btn_ok').click(function() { var correo = $('#registry #registry_email').val(); var clave = $('#registry #registry_password').val(); var nombre = $('#registry #registry_fistname').val(); var apellido = $('#registry #registry_lastname').val(); var casatel = $('#registry #registry_home_phone').val(); var direccion = $('#registry #registry_address').val(); var colonia = $('#registry #registry_address2').val(); var cp = $('#registry #registry_zip').val(); var ciudad = $('#registry #registry_city').val(); var estado = $('#registry #registry_state').val(); var pais = $('#registry #registry_country').val(); var razon = $('#registry #registry_irs_name').val(); var rfc = $('#registry #registry_rfc').val(); var oficinatel = $('#registry #registry_of_phone').val(); var celulartel = $('#registry #registry_cel_phone').val(); var direccion_irs = $('#registry #registry_irs_address').val(); var colonia_irs = $('#registry #registry_irs_address2').val(); var cp_irs = $('#registry #registry_irs_zip').val(); var ciudad_irs = $('#registry #registry_irs_city').val(); var estado_irs = $('#registry #registry_irs_state').val(); var pais_irs = $('#registry #registry_irs_country').val(); if(!correo.match(_.mail_regexp)) { $('#registry #registry_error_msg').html('Por favor ingrese una dirección de correo electronico válida'); return false; } if (clave == "") { $('#registry #registry_error_msg').html('Por favor ingresa una contraseña'); return false; } if (nombre == "") { $('#registry #registry_error_msg').html('Por favor ingresa tu nombre'); return false; } $('#registry #registry_error_msg').html('Procesando...'); $.post("index.php/mode,json/control,Users.register/", { email : correo, password : clave, firstname : nombre, lastname :apellido, phone_home : casatel, address_line1 : direccion, address_line2 : colonia, zip : cp, city : ciudad, state : estado, country : pais, irs_name : razon, rfc : rfc, phone_office : oficinatel, phone_cel : celulartel, irs_address_line1 : direccion_irs, irs_address_line2 : colonia_irs, irs_zip : cp_irs, irs_city : ciudad_irs, irs_state : estado_irs, irs_country : pais_irs }, function(json) { if (json.status === "OK") { $.unblockUI(); alert("Un correo ha sido enviado a la dirección proporcionada.

Por favor revísalo y activa tu cuenta."); } else { var status_message = json.status_message.toLowerCase(); if (status_message.indexOf("mailer error") >= 0) { $('#registry #registry_error_msg').html('Error al enviar el correo, intente más tarde.'); } else if (status_message.indexOf("email registered") >= 0) { $('#registry #registry_error_msg').html('La cuenta de correo ya existe en el sistema, intenta con otra.'); } else { $('#registry #registry_error_msg').html('Error desconocido.'); } } }, "json"); }); }, recover: function(){ $.blockUI({ message: $('#recover'), css: { width: '350px' } }); $('#recover #recover_cancel').click(function(){ $('#recover #recover_error_msg').html(''); $.unblockUI(); }); $('#recover #recover_ok').click(function() { if(!$("#recover #recover_email").val().match(_.mail_regexp)){ $('#recover #recover_error_msg').html('Por favor ingrese una dirección de correo electronico válida'); return false; } $('#recover #recover_error_msg').html('Procesando...'); $.post("index.php/mode,json/control,Users.recoverPassword/", { email: $('#recover #recover_email').val() }, function(json) { if (json.status === "OK") { $.unblockUI(); alert("Un correo ha sido enviado a la dirección proporcionada.

Por favor revísalo y activa tu cuenta."); } else { var status_message = json.status_message.toLowerCase(); if (status_message.indexOf("mailer error") >= 0) { $('#recover #recover_error_msg').html('Error al enviar el correo, intente más tarde.'); } else if (status_message.indexOf("user not exists") >= 0) { $('#recover #recover_error_msg').html('La cuenta de correo no existe en el sistema.'); } else { $('#recover #recover_error_msg').html('Error desconocido.'); } } }, "json"); }); }, account: function() { $.getJSON("index.php/mode,json/control,Users.edit/", function(json) { $('#account #account_password_hidden').val(json.result.password); $('#account #account_fistname').val(json.result.firstname); $('#account #account_lastname').val(json.result.lastname); $('#account #account_of_phone').val(json.result.phone_office); $('#account #account_home_phone').val(json.result.phone_home); $('#account #account_cel_phone').val(json.result.phone_cel); $('#account #account_address').val(json.result.address_line1); $('#account #account_address2').val(json.result.address_line2); $('#account #account_zip').val(json.result.zip); $('#account #account_city').val(json.result.city); $('#account #account_state').val(json.result.state); $('#account #account_country').val(json.result.country); $('#account #account_irs_name').val(json.result.irs_name); $('#account #account_rfc').val(json.result.irs_rfc); $('#account #account_irs_address').val(json.result.irs_address_line1); $('#account #account_irs_address2').val(json.result.irs_address_line2); $('#account #account_irs_zip').val(json.result.irs_zip); $('#account #account_irs_city').val(json.result.irs_city); $('#account #account_irs_state').val(json.result.irs_state); $('#account #account_irs_country').val(json.result.irs_country); $.blockUI({ message: $('#account'), css: { top: ($(window).height() - 350) /2 + 'px', left: ($(window).width() - 550) /2 + 'px', width: '550px' } }); $('#account #btn_cancel').click(function(){ $('#account #account_error_msg').html(''); $.unblockUI(); }); $('#account #btn_ok').click(function() { var clave = $('#account #account_password').val(); var nombre = $('#account #account_fistname').val(); var apellido = $('#account #account_lastname').val(); var casatel = $('#account #account_home_phone').val(); var direccion = $('#account #account_address').val(); var colonia = $('#account #account_address2').val(); var cp = $('#account #account_zip').val(); var ciudad = $('#account #account_city').val(); var estado = $('#account #account_state').val(); var pais = $('#account #account_country').val(); var razon = $('#account #account_irs_name').val(); var rfc = $('#account #account_rfc').val(); var oficinatel = $('#account #account_of_phone').val(); var celulartel = $('#account #account_cel_phone').val(); var direccion_irs = $('#account #account_irs_address').val(); var colonia_irs = $('#account #account_irs_address2').val(); var cp_irs = $('#account #account_irs_zip').val(); var ciudad_irs = $('#account #account_irs_city').val(); var estado_irs = $('#account #account_irs_state').val(); var pais_irs = $('#account #account_irs_country').val(); if (clave === "******" || password === "") { clave = $('#account #account_password_hidden').val(); } if (nombre === "") { $('#account #account_error_msg').html('Por favor ingresa tu nombre'); return false; } $('#account #account_error_msg').html('Procesando...'); $.post("index.php/mode,json/control,Users.saveEdit/", { password : clave, firstname : nombre, lastname :apellido, phone_home : casatel, address_line1 : direccion, address_line2 : colonia, zip : cp, city : ciudad, state : estado, country : pais, irs_name : razon, rfc : rfc, phone_office : oficinatel, phone_cel : celulartel, irs_address_line1 : direccion_irs, irs_address_line2 : colonia_irs, irs_zip : cp_irs, irs_city : ciudad_irs, irs_state : estado_irs, irs_country : pais_irs }, function(json) { if (json.status === "OK") { $.unblockUI(); alert("Tu información ha sido actualizada.", function() { window.location.reload(); }); } else { $('#registry #registry_error_msg').html('Error desconocido.'); } }, "json"); }); }); } } }); /* shop.js */ _.extend({ shop: { addProduct: function(id_product, product_name, product_model) { $.post("index.php/mode,json/control,Cart.addProduct/", { id_product: id_product }, function(json) { $('#little_cart_content_article').text(product_name + " " + product_model); if ($.browser.msie && $.browser.version.match(/^[0-6]/)) $('#little_cart').css({ top: document.documentElement.scrollTop, right: 10, position: "absolute" }); else $('#little_cart').css({ top: 10, right: 10, position: "fixed" }); $('#little_cart').fadeIn(); setTimeout(function() { $('#little_cart').fadeOut(); },5000); $('#total_productos').text(($('#total_productos').text() * 1) + 1); }, "json"); }, cart: function() { window.location.href = RCN.url + "index.php/page,cart/"; }, orders: function() { window.location.href = RCN.url + "index.php/page,orders/"; }, update: function(id) { var cantidad = $('#cant_'+id).val(); var id_order = $('#id_order').val(); var cantidad_old = $('#total_productos').text() * 1; var numberMatch = /^[0-9]*$/; if(cantidad == "0" || cantidad == "" || cantidad == " "){ $('#cant_'+id).val(1); alert("No se permiten los campos vacios o en 0. Si no deseas este producto eliminalo"); return false; } if (cantidad.match(numberMatch)) $.post("index.php/mode,json/control,Cart.updateProduct/", { id_order: id_order, id: id, amount: cantidad }, function(json){ $('#total_productos').text(json.total_productos); $('#subtotal_' + id).text("$" + json.subtotal + ".00"); }, "json"); else { $('#cant_'+id).val(1); alert("Solo se permiten números"); } }, remove: function(id) { var id_order = $('#id_order').val(); $.post("index.php/mode,json/control,Cart.deleteProduct/", { id_order:id_order, id:id }, function(json){ $('#total_productos').text(($('#total_productos').text() * 1) - $('#cant_'+id).val()); $('#producto_'+id).slideUp(); }, "json"); }, validateCheckout: function() { $.post("index.php/mode,json/control,Users.getIsLogged/", {}, function(json){ if (json.result === "") { _.users.login(); } else { window.location.href = RCN.url + "index.php/page,checkout/"; } }, "json"); }, checkout: function(id_order) { loading("Tu pedido está siendo ordenado.

Por Favor Espera.

Gracias."); $.post("index.php/mode,json/control,Cart.makeOrder/", { id_order:id_order, total_monto:$('#total_monto').text(), total_productos:$('#total_productos').text() }, function(json){ alert("" + "Tu pedido ha sido ordenado.

" + "En breve un ejecutivo se contactará contigo.

" + "Puedes ver el status de tu pedido haciendo clic en el botón de Historial de Compras.

" + "Gracias.", function() { window.location.href = RCN.url + "index.php/page,index/"; }); }, "json"); }, keepShopping: function() { alert(document.referrer); //window.location.href = document.referrer; } } }); /* newsletter.js */ _.extend({ newsletter: { suscribe: function() { var nombre = $("input#newsletter_name").val(); var correo = $("input#newsletter_email").val(); if (!correo.match(_.mail_regexp)) { alert("Por favor ingresa una dirección de correo válida"); return false; } if (nombre == "") { alert("Por favor ingresa tu nombre"); return false; } $.post("index.php/mode,json/control,Newsletter.suscribe/", { name: nombre, email: correo }, function(json) { if (json.status === "OK") { alert("Gracias por suscribirte a nuesto Newsletter.

Recibirás las últimas noticias por correo."); } else { alert("Dirección de correo existente

Por favor intenta con otra."); } }, "json"); } } }); /* cotiza.js */ _.extend({ cotiza: function(){ var nombre = $('#cotiza_name').val(); var correo = $('#cotiza_email').val(); var lada = $('#cotiza_lada').val(); var telefono = $('#cotiza_telefono').val(); var origen = $('#cotiza_origen').val(); var destino = $('#cotiza_destino').val(); var salida_dia = $('#cotiza_salida_dia').val(); var salida_mes = $('#cotiza_salida_mes').val(); var salida_ano = $('#cotiza_salida_ano').val(); var regreso_dia = $('#cotiza_regreso_dia').val(); var regreso_mes = $('#cotiza_regreso_mes').val(); var regreso_ano = $('#cotiza_regreso_ano').val(); var adultos = $('#cotiza_adultos').val(); var menores = $('#cotiza_menores').val(); var avion; var hotel; var auto; var seguro; var comentarios_cotiza = $('#cotiza_comentarios_cotiza').val(); if($('#cotiza_avion').checked) avion = "avion"; else avion = ""; if($('#cotiza_hotel').checked) hotel = "hotel"; else hotel = ""; if($('#cotiza_auto').checked) auto = "auto"; else auto = ""; if($('#cotiza_seguro').checked) seguro = "seguro"; else seguro = ""; if (!correo.match(_.mail_regexp)) { alert("Por favor ingresa una dirección de correo válida"); return false; } loading(); $.post("index.php/mode,json/control,CotizaViaje.sendMail/", { nombre :nombre, correo : correo, lada : lada, telefono : telefono, origen : origen, destino : destino, salida_dia : salida_dia, salida_mes : salida_mes, salida_ano : salida_ano, regreso_dia : regreso_dia, regreso_mes : regreso_mes, regreso_ano : regreso_ano, adultos : adultos, menores : menores, avion : avion, hotel : hotel, auto : seguro, seguro : seguro, comentarios_cotiza : comentarios_cotiza }, function(json) { if (json.status === "OK") { alert("Tu cotización ha sido enviada.

En breve un ejecutivo se pondrá en contacto contigo."); } else { alert("Error al enviar tus datos, intenta de nuevo en un rato."); } }, "json"); } }); /* clima.js */ _.extend({ clima: { getCities: function() { $("#rmt_cities").load("index.php/mode,run/control,Clima.getCities", {country: document.climaactual.country.value}); }, getCityTemp: function(city_value) { $("#rmt_city").load("index.php/mode,run/control,Clima.getCity", {city: city_value}); }, getPregoguias: function() { $("#rmt_pregoguia").load("index.php/mode,run/control,Clima.getPregoguias", {continent: document.climaactual.continent.value}); }, downloadPregoguia: function(filepath) { if (filepath != "") { var pregoguiawin = window.open(filepath, "", "width=800,height=500,resizable=true"); } } } });